﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Planer.Model.Validators.Base;

namespace Planer.Model.Validators
{
    public class UserValidator : Validator<user>
    {
        public override void Validate(user User)
        {
            if (User == null) throw new ArgumentNullException("User", NULL_ARGUMENT_MESSAGE);
            NameValidator nameValidator = new NameValidator();
            nameValidator.Validate(User.name);
            if (nameValidator.Status == OperationStatusType.ERROR)
            {
                this.status = OperationStatusType.ERROR;
                this.errors.AddRange(nameValidator.Errors);
            }

            EmailValidator emailValidator = new EmailValidator();
            emailValidator.Validate(User.email);
            if (emailValidator.Status == OperationStatusType.ERROR)
            {
                this.status = OperationStatusType.ERROR;
                this.Errors.AddRange(emailValidator.Errors);
            }

            PasswordValidator passwordValidator = new PasswordValidator();
            passwordValidator.Validate(User.password_hash);
            if (passwordValidator.Status == OperationStatusType.ERROR)
            {
                this.status = OperationStatusType.ERROR;
                this.errors.AddRange(passwordValidator.Errors);
            }
        }
    }
}
